﻿using System;
using System.Collections.Generic;
using System.Text;
using Meqs.Logic.Interface;
using Meqs.Entity;
using System.Collections;

namespace Meqs.Logic.Implement
{
    public class StudentHistoryLogic : CommonLogic<StudentHistory, int>, IStudentHistoryLogic
    {

        #region ICommonLogic<StudentHistory,int> 成员

        public int Create(StudentHistory entity)
        {
            try
            {
                string statementName = "StudentHistory.Insert";
                ExecuteInsert(statementName, entity);
            }
            catch (Exception ex)
            {
                throw;
            }
            return 1;
        }

        public int Update(StudentHistory entity)
        {
            return UpdateObject(entity);
        }

        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        public StudentHistory FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        public int FindCount()
        {
            return FindObjectByCount();
        }

        public IList<StudentHistory> FindAll()
        {
            return FindAllObject();
        }

        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        public IList<StudentHistory> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="ht"></param>
         public void DeleteStudentHistory(Hashtable ht)
        {
            try
            {
                string statementName = "StudentHistory.DeleteStudentHistory";
                ExecuteDelete(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 更新班级
        /// </summary>
        /// <param name="ht"></param>
        public void UpdateStudentClass(Hashtable ht)
        {
            try
            {
                string statementName = "StudentHistory.UpdateStudentClass";
                ExecuteUpdate(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// 升级学年时调用增加学生的班级就读记录
        /// </summary>
        /// <param name="ht"></param>
        public void InsertNewStudentHistory(Hashtable ht)
        {
            try
            {
                string statementName = "StudentHistory.InsertNewStudentHistory";
                ExecuteInsert(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        /// <summary>
        /// 查询全部
        /// </summary>
        /// <returns></returns>
        public  IList<StudentInfo> FindHistoryStudents(int schoolYear, int term, int classID, String schoolMark)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("SchoolYear", schoolYear);
                ht.Add("Term", term);
                ht.Add("ClassID", classID);
                ht.Add("SchoolMark", schoolMark);
                string statementName = "StudentHistory.FindHistoryStudents";
                return ExecuteQueryForList<StudentInfo>(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
    }
}
